/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ghanaroutes.entities;

import com.alerts.Alert;
import com.alerts.Comment;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author User
 */
@Entity
@Table(name = "users")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"),
    @NamedQuery(name = "Users.findByUserId", query = "SELECT u FROM Users u WHERE u.userId = :userId"),
    @NamedQuery(name = "Users.findByUsername", query = "SELECT u FROM Users u WHERE u.username = :username"),
    @NamedQuery(name = "Users.findByPhoneNo", query = "SELECT u FROM Users u WHERE u.phoneNo = :phoneNo"),
    @NamedQuery(name = "Users.findByInvisible", query = "SELECT u FROM Users u WHERE u.invisible = :invisible"),
    @NamedQuery(name = "Users.findByCurrentLoc", query = "SELECT u FROM Users u WHERE u.currentLoc = :currentLoc"),
    @NamedQuery(name = "Users.findByCurrentlocName", query = "SELECT u FROM Users u WHERE u.currentlocName = :currentlocName"),
    @NamedQuery(name = "Users.findByCurrentCity", query = "SELECT u FROM Users u WHERE u.currentCity = :currentCity"),
    @NamedQuery(name = "Users.findByDateAdded", query = "SELECT u FROM Users u WHERE u.dateAdded = :dateAdded")})
public class Users implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "user_id")
    private Integer userId;
    @Size(max = 25)
    @Column(name = "username")
    private String username;
    @Size(max = 15)
    @Column(name = "phoneNo")
    private String phoneNo;
    @Column(name = "invisible")
    private Short invisible;
    @Size(max = 20)
    @Column(name = "current_loc")
    private String currentLoc;
    @Size(max = 50)
    @Column(name = "current_locName")
    private String currentlocName;
    @Size(max = 50)
    @Column(name = "current_city")
    private String currentCity;
    @Column(name = "date_added")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateAdded;
    
    @OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
    private List<Alert> alerts;

    public List<Alert> getAlerts() {
        return alerts;
    }

    public void setAlerts(List<Alert> alerts) {
        this.alerts = alerts;
    }
    

    @OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
    private List<Comment> comments;

    public List<Comment> getComments() {
        return comments;
    }

    public void setComments(List<Comment> comments) {
        this.comments = comments;
    }
    
    
    
    public Users() {
    }

    public Users(Integer userId) {
        this.userId = userId;
    }

    public Users(Integer userId, Date dateAdded) {
        this.userId = userId;
        this.dateAdded = dateAdded;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPhoneNo() {
        return phoneNo;
    }

    public void setPhoneNo(String phoneNo) {
        this.phoneNo = phoneNo;
    }

    public Short getInvisible() {
        return invisible;
    }

    public void setInvisible(Short invisible) {
        this.invisible = invisible;
    }

    public String getCurrentLoc() {
        return currentLoc;
    }

    public void setCurrentLoc(String currentLoc) {
        this.currentLoc = currentLoc;
    }

    public String getCurrentlocName() {
        return currentlocName;
    }

    public void setCurrentlocName(String currentlocName) {
        this.currentlocName = currentlocName;
    }

    public String getCurrentCity() {
        return currentCity;
    }

    public void setCurrentCity(String currentCity) {
        this.currentCity = currentCity;
    }

    public Date getDateAdded() {
        return dateAdded;
    }

    public void setDateAdded(Date dateAdded) {
        this.dateAdded = dateAdded;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userId != null ? userId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Users)) {
            return false;
        }
        Users other = (Users) object;
        if ((this.userId == null && other.userId != null) || (this.userId != null && !this.userId.equals(other.userId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ghanaroutes.entities.Users[ userId=" + userId + " ]";
    }
    
}
